<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>校园帮API测试页面</title>
    <link rel="icon" href="/favicon.ico" type="image/x-icon">
    <style>
        body { font-family: Arial, sans-serif; margin: 40px; }
        .test-section { margin: 20px 0; padding: 20px; border: 1px solid #ddd; border-radius: 8px; }
        button { padding: 10px 20px; margin: 5px; background: #007bff; color: white; border: none; border-radius: 4px; cursor: pointer; }
        button:hover { background: #0056b3; }
        .result { margin-top: 10px; padding: 10px; background: #f8f9fa; border-radius: 4px; }
        input, textarea { width: 100%; padding: 8px; margin: 5px 0; border: 1px solid #ddd; border-radius: 4px; }
    </style>
</head>
<body>
    <h1>校园帮API测试页面</h1>
    <p>当前时间: <span id="time"></span></p>
    
    <!-- 外卖代取API测试 -->
    <div class="test-section">
        <h2>外卖代取API测试</h2>
        <div>
            <label>配送地址:</label>
            <input type="text" id="deliveryAddress" value="测试地址" />
        </div>
        <div>
            <label>服务时间:</label>
            <input type="text" id="serviceTime" value="今日, 20:00-20:30" />
        </div>
        <div>
            <label>外卖描述:</label>
            <textarea id="foodDescription" rows="3">测试外卖描述</textarea>
        </div>
        <div>
            <label>小费金额:</label>
            <input type="number" id="tipAmount" value="2" />
        </div>
        <button onclick="testFoodPickup()">测试创建外卖代取订单</button>
        <div id="foodPickupResult" class="result"></div>
    </div>
    
    <script>
        document.getElementById('time').textContent = new Date().toLocaleString('zh-CN');
        
        async function testFoodPickup() {
            const resultDiv = document.getElementById('foodPickupResult');
            resultDiv.innerHTML = '请求中...';
            
            try {
                const data = {
                    deliveryAddress: document.getElementById('deliveryAddress').value,
                    serviceTime: document.getElementById('serviceTime').value,
                    foodDescription: document.getElementById('foodDescription').value,
                    tipAmount: parseInt(document.getElementById('tipAmount').value),
                    baseFee: 3,
                    totalAmount: 3 + parseInt(document.getElementById('tipAmount').value)
                };
                
                const response = await fetch('/food-pickup/create', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json'
                    },
                    body: JSON.stringify(data)
                });
                
                const result = await response.json();
                resultDiv.innerHTML = `<strong>响应状态:</strong> ${response.status}<br>
                                    <strong>响应数据:</strong> <pre>${JSON.stringify(result, null, 2)}</pre>`;
            } catch (error) {
                resultDiv.innerHTML = `<strong>错误:</strong> ${error.message}`;
            }
        }
    </script>
</body>
</html>
